﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace ScreenShark
{
    public partial class PreviewForm : Form
    {
        public PreviewForm()
        {
            InitializeComponent();           
        }

        public event EventHandler ContinueClicked;

        public Image PreviewImage
        {
            get { return selectablePictureBox.Image; }
            set { selectablePictureBox.Image = value; }
        }

        public Image GetResultImage()
        {
            return selectablePictureBox.HasSelectedRectangle ? selectablePictureBox.GetSelectedImage() : PreviewImage;
        }

        private void PreviewForm_Load(object sender, EventArgs e)
        {

        }

        private void continueWithouSavingButton_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void continueButton_Click(object sender, EventArgs e)
        {
            if (null != ContinueClicked)
                ContinueClicked(this, EventArgs.Empty);

            Close();
        }

        private void selectablePictureBox_MouseMove(object sender, MouseEventArgs e)
        {
            if (selectablePictureBox.HasSelectedRectangle)
            {
                var r = selectablePictureBox.SelectedRectangle;

                string s = String.Format("Region: {0} x {1}", r.Width, r.Height);
                regionToolStripStatusLabel.Text = s;
            }
        }

        private void selectablePictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            if (!selectablePictureBox.HasSelectedRectangle)
                regionToolStripStatusLabel.Text = "Region is not selected.";
        }
    }
}
